package com.yuyou.fn.timer.task;


import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.yuyou.fn.common.util.BeanUtils;
import com.yuyou.fn.platform.entity.AreaTeam;
import com.yuyou.fn.platform.service.IAreaTeamService;
import com.yuyou.fn.portal.service.IConfigService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * 更新网报课程筛选条件
 * Created by wens on 2018/6/19.
 */
@JobHander(value="UpdateCourseFilterCondConfigTask")
@Component
public class UpdateCourseFilterCondConfigTask extends IJobHandler {

    @Resource
    private IAreaTeamService areaTeamService;

    @Resource
    private IConfigService configService;

    @Override
    public ReturnT<String> execute(String... params) throws Exception {

        List<AreaTeam> allAreaTeams = areaTeamService.findAllAreaTeam();
        List<Long> areaTeamIds  = BeanUtils.toList(allAreaTeams,"areaTeamId");
        configService.updateCourseFilterCondConfig(areaTeamIds);

        return ReturnT.SUCCESS ;
    }
}
